package com.heima.commnet.feign;

import com.heima.apis.comment.ICommentClient;
import com.heima.commnet.service.CommentRepayService;
import com.heima.commnet.service.CommentService;
import com.heima.model.article.dtos.ArticleCommentDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommentClient implements ICommentClient {
    @Autowired
    private CommentService commentService;
    @Autowired
    private CommentRepayService commentRepayService;

    @Override
    @PostMapping("/api/v1/comment/commentLike/{authorId}")
    public ResponseResult commentLike(@RequestBody ArticleCommentDto dto, @PathVariable Integer authorId) {
        return commentService.commentLike(dto, authorId);
    }

    @PostMapping("/api/v1/comment/manage/saveCommentRepay/{authorId}/{name}")
    public ResponseResult saveCommentRepay(@RequestBody ArticleCommentDto dto, @PathVariable Integer authorId, @PathVariable String name) {
        return commentRepayService.saveCommentRepay(dto, authorId, name);
    }
}
